﻿using MediatR;
using System.CJL.API.Application.Command.FinishedProductsCommand;
using System.CJL.Domain;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.FinishedProductsCommandHanler
{
    /// <summary>
    /// 显示
    /// </summary>
    public class FinishedProductsPiShowCommandHandler : IRequestHandler<FinishedProductsPiShowCommand, List<FinishedProduct>>
    {
        IFinishedProductRepositry _repositry;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="repositry"></param>
        public FinishedProductsPiShowCommandHandler(IFinishedProductRepositry repositry)
        {
            _repositry= repositry;
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<FinishedProduct>> Handle(FinishedProductsPiShowCommand request, CancellationToken cancellationToken)
        {
            var list = (await _repositry.GetAll()).Where(x => request.Id.Contains(x.finishedProductId)).ToList();
            return list;
        }
    }
}
